package com.dob.app;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.dob.dbo.jdbc.CRUDUsingJDBCTemplate;
import com.dob.dbo.jdbc.DataSourceExample;
import com.dob.dbo.jdbc.JDBCTemplateExample;
import com.dob.dbo.jdbc.NamedParameterJDBCTemplateExample;
import com.dob.dbo.jdbc.RowMapperExample;
import com.dob.model.Employee;

public class JDBCTest {
	
	public static void main(String args[]){
		
		
		AbstractApplicationContext context= new ClassPathXmlApplicationContext("spring.xml");
		context.registerShutdownHook();
//		DataSourceExample dsExample=(DataSourceExample)context.getBean("dataSourceExample");
//		dsExample.getEmployee();
		
//		JDBCTemplateExample jdbcTemplateExample=(JDBCTemplateExample)context.getBean("jdbcTemplateExample");
//		jdbcTemplateExample.getEmployeeCount();
//		jdbcTemplateExample.getEmployeeName(9876);
		
		RowMapperExample rowMapperExample=(RowMapperExample)context.getBean("rowMapperExample");
		System.out.println(rowMapperExample.getEmployee(98765).getEmpName());
		System.out.println(rowMapperExample.getAllEmployee().size());
		
//		CRUDUsingJDBCTemplate CRUDUsingJDBCTemplate=(CRUDUsingJDBCTemplate)context.getBean("CRUDUsingJDBCTemplate");
//		System.out.println("Before Insert: "+CRUDUsingJDBCTemplate.getAllEmployee().size());
//		Employee emp=CRUDUsingJDBCTemplate.getEmployee(1234);
//		CRUDUsingJDBCTemplate.insertEmployee(emp);
//		System.out.println("After Insert: "+CRUDUsingJDBCTemplate.getAllEmployee().size());
		
//		NamedParameterJDBCTemplateExample namedParameterJDBCTemplateExample=(NamedParameterJDBCTemplateExample)context.getBean("namedParameterJDBCTemplateExample");
//		System.out.println("Before Insert: "+namedParameterJDBCTemplateExample.getAllEmployee().size());
//		Employee emp=namedParameterJDBCTemplateExample.getEmployee(9876);
//		namedParameterJDBCTemplateExample.insertEmployeeUsingNamedParameter(emp);
//		System.out.println("After Insert: "+namedParameterJDBCTemplateExample.getAllEmployee().size());
		
	}

}
